﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>工作查看</title>
    <link href="../../Scripts/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.11.0.min.js"></script>
    <script src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>

    <style>
        .panel-body {
            border-color: #f2f2f2;
        }

        .tabs-scroller-right {
            border-color: #f2f2f2
        }

        .tabs-header {
            border-color: #f2f2f2;
            background-color: #f2f2f2
        }

        #mtabs {
            border-color: #f2f2f2
        }

        .tab-content, .tab-pane {
            height: 100%;
            padding-bottom: 20px;
        }

        .tabs {
            background: #f2f2f2;
            border: 1px solid #f2f2f2;
        }

            .tabs li a.tabs-inner {
                background: #f2f2f2;
                border: 1px solid #f2f2f2;
            }
    </style>
    <script type="text/javascript">
        var MenuIdx = 1;
        var currtab = GetQueryString("CurrTab");
        var fk_node = GetQueryString("FK_Node");
        var fk_flow = GetQueryString("FK_Flow");
        var workid = GetQueryString("WorkID");
        var fid = GetQueryString("FID");
        var tpo = {};

        $(function () {

            $("#mtabs").tabs({
                onSelect: function (title, index) {
                    document.title = title;
                    var currTab = $('#mtabs').tabs('getSelected');
                    var url = $(currTab.panel('options').content).attr('src');
                    if (url != undefined) {
                        $('#mtabs').tabs('update', {
                            tab: currTab,
                            options: {
                                content: createFrame(url)
                            }
                        })
                    }
                }
            });

            //
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("OneWork_GetTabs");
            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            if (data == "[]") {
                return;
            }

            data = cceval('(' + data + ')');
            var IsDefaultTab = null;
            $.each(data, function (index, obj) {
                
                if (obj.No =="Truck")
                    $("#OneWorkTab").append("<li class='active'><a data-toggle='tab' href='#" + obj.No + "'>" + obj.Name + "</a></li>");
                else
                    $("#OneWorkTab").append("<li><a data-toggle='tab' href='#" + obj.No + "'>" + obj.Name + "</a></li>");
                addTab(this.No, this.Name, this.Url);
                tpo[this.No] = this.Name;
            });
            if (IsDefaultTab != null) {
                $("#mtabs").tabs("select", IsDefaultTab);
            } else {
                if (currtab == false) {

                    $("#mtabs").tabs("select", 0);
                }
                else {

                    $("#mtabs").tabs("select", tpo[currtab]);
                }
            }
            if (window.screen) {
                var w = screen.availWidth;
                var h = screen.availHeight;
                window.moveTo(0, 0);
                window.resizeTo(w, h);
            }
            //隐藏老的tab页
            $(".tabs").hide();
        });

        function addTab(id, title, url) {

            //   alert(url);

            if ($('#mtabs').tabs('exists', title)) {
                $('#mtabs').tabs('select', title); //选中并刷新
                var currTab = $('#mtabs').tabs('getSelected');
            } else {

                if (url.indexOf('FK_Node') == -1)
                    url += "&FK_Node=" + GetQueryString("FK_Node");

                if (url.indexOf('WorkID') == -1)
                    url += "&WorkID=" + GetQueryString("WorkID");

                if (url.indexOf('FK_Flow') == -1)
                    url += "&FK_Flow=" + GetQueryString("FK_Flow");

                if (url.indexOf("@url=") == 0) {
                    url = url.replace("@url=", "");
                    if (url.indexOf("http") == -1)
                        url = basePath + url;
                }

                var content = createFrame(url);
                var htm = '';
                if (id == "Truck")
                    htm += '<div id="' + id + '" class="tab-pane fade in active">';
                else
                    htm += '<div id="' + id + '" class="tab-pane fade">';
                htm += '    <iframe scrolling="auto" frameborder="0" src="' + url + '" style="width:100%;height:100%;"></iframe>';
                htm += '</div>';
                $(".tab-content").append(htm)
                MenuIdx++;
              
            }
        }

        function createFrame(url) {
            return '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
        }

        function RSize() {
            if (document.body.scrollWidth > (window.screen.availWidth - 100)) {
                window.dialogWidth = (window.screen.availWidth - 100).toString() + "px"
            } else {
                window.dialogWidth = (document.body.scrollWidth + 50).toString() + "px"
            }

            if (document.body.scrollHeight > (window.screen.availHeight - 70)) {
                window.dialogHeight = (window.screen.availHeight - 50).toString() + "px"
            } else {
                window.dialogHeight = (document.body.scrollHeight + 115).toString() + "px"
            }
            window.dialogLeft = ((window.screen.availWidth - document.body.clientWidth) / 2).toString() + "px"
            window.dialogTop = ((window.screen.availHeight - document.body.clientHeight) / 2).toString() + "px"
        }
    </script>

</head>
<body class="easyui-layout">
    <div data-options="region:'center',noheader:true">
        <ul style="margin-left:10px" class="nav nav-tabs" id="OneWorkTab">
          
        </ul>
        <div class="tab-content">

        </div>
        <!--老的tab样式-->
        <div id="mtabs" class="easyui-tabs" data-options="fit:true">
        </div>
    </div>
</body>
</html>
